<%@page import="com.railway.files.model.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>

<html>

<head>
	<link rel="stylesheet" type="text/css" href="${ctx}/css/default.css" />

		
		
		<link href="${ctx}/commons/upload/css/uploadify.css" rel="stylesheet" type="text/css" />
		
		
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.2.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.4.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/swfobject.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/jquery.uploadify.v2.1.4.js"></script>

	
	<script type="text/javascript"> 	
	
	function deleteUploadedFiles(){
	      jQuery('#fileupload').uploadifyClearQueue();
	      form1.uploadedfileid.value = "";
	      $('.files').empty();
        
	     /* if(form1.uploadedfileid.value == '') return;
		     $.get("${ctx}/files/Files/deleteByAjax.do?t="+Math.random(), {
                Action:"get","fileTypes":"ADDRESS",uploadedfileid:form1.uploadedfileid.value}, function (data, textStatus){	
   	              $('.files').empty();
         		  $('#filename').empty();
         		  form1.uploadedfileid.value = "";
         		
     
		   });	   */
	}
	        $(document).ready(function() { 

     //首先去查一下通讯录
                
	           $.get("${ctx}/web/Web/getPayment.do", {
                Action:"get",Name:""}, function (data, textStatus){	
    
                
          
                 var objs = eval("["+data+"]");	               
	               if(objs[0].addressid =='' || objs[0].addressid == undefined) return;
	                
			      	$('#filename').append('<a href="${ctx}/files/Files/download.do?fileTypes=PAYMENT&fileName='+objs[0].addressid+'">'+objs[0].addressname+'</a>');
		        
				});	
	           
	        	
	            $("#fileupload").uploadify({
	           
	                 'allBytesLoaded':300 * 1024*1024,
	                /*注意前面需要书写path的代码*/ 
	                'uploader'       : '${ctx}/commons/upload/js/uploadify.swf', 
	                'script'         : '${ctx}/files/Files/upload.do?fileTypes=PAYMENT', 
	                'cancelImg'      : '${ctx}/commons/upload/images/cancel.png', 
	                'queueID'        : 'fileQueue', //和存放队列的DIV的id一致 
	                'fileDataName'   : 'fileupload', //和以下input的name属性一致 
	                'auto'           : false, //是否自动开始 
	                'multi'          : false, //是否支持多文件上传 
	                'buttonText'     : '选择文件', //按钮上的文字 
	                'simUploadLimit' : 1, //一次同步上传的文件数目 
	                'sizeLimit'      : 30* 1024 * 1024, //设置单个文件大小限制 
	                'queueSizeLimit' : 1, //队列中同时存在的文件个数限制 
	                'fileDesc'       : '支持格式:html', //如果配置了以下的'fileExt'属性，那么这个属性是必须的 
	                'fileExt'        : '*.html',//允许的格式   
	            onComplete: function (event, queueID, fileObj, response, data) { 
      			     var objs = eval("["+response+"]");	               
	                 form1.uploadedfileid.value = objs[0].uploadedfileid;            
	                
					 $('<li></li>').appendTo('.files').text(objs[0].uploadedresult); 
					 
					 $('#filename').html('<a href="${ctx}/files/Files/download.do?fileTypes=PAYMENT&fileName='+objs[0].addressid+'">'+objs[0].addressname+'</a>');
	}, 
	       		onError: function(event, queueID, fileObj) { 
	             	alert("文件:" + fileObj.name + "上传失败"); 
	       }, 
	      	 	onCancel: function(event, queueID, fileObj){ 
	       		//	alert("取消了" + fileObj.name); 
	       } 
	       }); 


	
	        }); 
	        </script> 
	
	<script type="text/javascript"> 
	      
	function uploadifyUpload(){ 
 
	     if(form1.uploadedfileid.value  != null &&  form1.uploadedfileid.value != ""){
	                   alert("附件已添加!");
	                   return;
	     }
 
	   $('#fileupload').uploadifyUpload(); 
	} 
	</script> 
	
	
	<title>维护支出动态表</title>
</head>
<body>
	<form id="form1"  method="post">
	    
		
		<input type="hidden" name="uploadedfileid"	value="${model.uploadedfileid}" />
		

		
	</form>
	  <table>
	   <tr> 
	<td>下载支出动态表：</td> 
	<td> 
	 
	<div id="filename"></div> 
 
 
	</td> 
	</tr>
	   <tr> 
	<td>上传支出动态表：</td> 
	<td> 
	<input type="file" name="fileupload" id="fileupload" /> 
	<div id="fileQueue"></div> 
	<p> 
	<a href="javascript:;" onClick="javascript:uploadifyUpload()">开始上传</a>&nbsp; 
	<a href="javascript:deleteUploadedFiles();">取消所有上传</a> 
	</p> 
	<ol class=files></ol> 
	</td> 
	</tr>
 </table>
	
</body>
<script>
//begin $(document).ready(handler)
$(function(){
$('#form1').submit(function(){
	return $('#form1').form('validate');
});}
);//end $(document).ready(handler)
</script>
</html>

